package com.tsing.cedap.rest.controller;

import com.tsing.cedap.common.annotations.SystemLog;
import com.tsing.cedap.common.utils.ResultUtil;
import com.tsing.cedap.common.valid.AddGroup;
import com.tsing.cedap.common.valid.UpdateGroup;
import com.tsing.cedap.common.vo.PageResult;
import com.tsing.cedap.common.vo.ResultData;
import com.tsing.cedap.rest.service.IWebSchoolService;
import com.tsing.cedap.rest.vo.reqVo.*;
import com.tsing.cedap.rest.vo.respVo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author TheTsing
 * @create 2022-03-29 11:13
 */
@Api(tags = "web端学校管理模块")
@RestController
@RequestMapping("/webSchool")
public class WebSchoolController {

    @Autowired
    private IWebSchoolService webSchoolService;

    @PostMapping("/addSchool")
    @ApiOperation(value = "新增学校")
    @SystemLog(description = "新增学校")
    public ResultData addSchool(@Validated({AddGroup.class}) @RequestBody SchoolReqVo reqVo) {
        webSchoolService.addSchool(reqVo);
        return ResultUtil.success();
    }

    @DeleteMapping("/deleteSchool")
    @ApiOperation(value = "删除学校")
    @SystemLog(description = "删除学校")
    public ResultData deleteSchool(@Validated @RequestBody IdsReqVo reqVo) {
        webSchoolService.deleteSchool(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/getSchool")
    @ApiOperation(value = "获取学校信息")
    public ResultData<SchoolRespVo> getSchool(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(webSchoolService.getSchool(reqVo));
    }

    @PutMapping("/updateSchool")
    @ApiOperation(value = "修改学校信息")
    @SystemLog(description = "修改学校信息")
    public ResultData updateSchool(@Validated({UpdateGroup.class}) @RequestBody SchoolReqVo reqVo) {
        webSchoolService.updateSchool(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/schoolPage")
    @ApiOperation(value = "学校分页")
    public ResultData<PageResult<SchoolRespVo>> schoolPage(@Validated NameAndPhonePageReqVo reqVo) {
        return ResultUtil.success(webSchoolService.schoolPage(reqVo));
    }

    /**
     * 校区管理
     **/
    @PostMapping("/addCampus")
    @ApiOperation(value = "新增校区")
    @SystemLog(description = "新增校区")
    public ResultData addCampus(@Validated({AddGroup.class}) @RequestBody CampusReqVo reqVo) {
        webSchoolService.addCampus(reqVo);
        return ResultUtil.success();
    }

    @DeleteMapping("/deleteCampus")
    @ApiOperation(value = "删除校区")
    @SystemLog(description = "删除校区")
    public ResultData deleteCampus(@Validated @RequestBody IdsReqVo reqVo) {
        webSchoolService.deleteCampus(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/getCampus")
    @ApiOperation(value = "获取校区信息")
    public ResultData<CampusRespVo> getCampus(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(webSchoolService.getCampus(reqVo));
    }

    @PutMapping("/updateCampus")
    @ApiOperation(value = "修改校区信息")
    @SystemLog(description = "修改校区信息")
    public ResultData updateCampus(@Validated({UpdateGroup.class}) @RequestBody CampusReqVo reqVo) {
        webSchoolService.updateCampus(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/campusPage")
    @ApiOperation(value = "校区分页")
    public ResultData<PageResult<CampusRespVo>> campusPage(@Validated NameAndPhonePageReqVo reqVo) {
        return ResultUtil.success(webSchoolService.campusPage(reqVo));
    }

    /**
     * 学院管理
     */
    @PostMapping("/addCollege")
    @ApiOperation(value = "新增学院")
    @SystemLog(description = "新增学院")
    public ResultData addCollege(@Validated({AddGroup.class}) @RequestBody CollegeReqVo reqVo) {
        webSchoolService.addCollege(reqVo);
        return ResultUtil.success();
    }

    @DeleteMapping("/deleteCollege")
    @ApiOperation(value = "删除学院")
    @SystemLog(description = "删除学院")
    public ResultData deleteCollege(@Validated @RequestBody IdsReqVo reqVo) {
        webSchoolService.deleteCollege(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/getCollege")
    @ApiOperation(value = "获取学院信息")
    public ResultData<CollegeRespVo> getCollege(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(webSchoolService.getCollege(reqVo));
    }

    @PutMapping("/updateCollege")
    @ApiOperation(value = "修改学院信息")
    @SystemLog(description = "修改学院信息")
    public ResultData updateCollege(@Validated({UpdateGroup.class}) @RequestBody CollegeReqVo reqVo) {
        webSchoolService.updateCollege(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/collegePage")
    @ApiOperation(value = "学院分页")
    public ResultData<PageResult<CollegeRespVo>> collegePage(@Validated NameAndPhonePageReqVo reqVo) {
        return ResultUtil.success(webSchoolService.collegePage(reqVo));
    }

    /**
     * 驿站管理
     **/
    @PostMapping("/addStation")
    @ApiOperation(value = "新增驿站")
    @SystemLog(description = "新增驿站")
    public ResultData addStation(@Validated({AddGroup.class}) @RequestBody StationReqVo reqVo) {
        webSchoolService.addStation(reqVo);
        return ResultUtil.success();
    }

    @DeleteMapping("/deleteStation")
    @ApiOperation(value = "删除驿站")
    @SystemLog(description = "删除驿站")
    public ResultData deleteStation(@Validated @RequestBody IdsReqVo reqVo) {
        webSchoolService.deleteStation(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/getStation")
    @ApiOperation(value = "获取驿站信息")
    public ResultData<StationRespVo> getStation(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(webSchoolService.getStation(reqVo));
    }

    @PutMapping("/updateStation")
    @ApiOperation(value = "修改驿站信息")
    @SystemLog(description = "修改驿站信息")
    public ResultData updateStation(@Validated({UpdateGroup.class}) @RequestBody StationReqVo reqVo) {
        webSchoolService.updateStation(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/stationPage")
    @ApiOperation(value = "驿站分页")
    public ResultData<PageResult<StationRespVo>> stationPage(@Validated NameAndPhonePageReqVo reqVo) {
        return ResultUtil.success(webSchoolService.stationPage(reqVo));
    }

    /**
     * 快递品牌管理
     **/
    @PostMapping("/addBrand")
    @ApiOperation(value = "新增品牌")
    @SystemLog(description = "新增品牌")
    public ResultData addBrand(@Validated({AddGroup.class}) @RequestBody BrandReqVo reqVo) {
        webSchoolService.addBrand(reqVo);
        return ResultUtil.success();
    }

    @DeleteMapping("/deleteBrand")
    @ApiOperation(value = "删除品牌")
    @SystemLog(description = "删除品牌")
    public ResultData deleteBrand(@Validated @RequestBody IdsReqVo reqVo) {
        webSchoolService.deleteBrand(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/getBrand")
    @ApiOperation(value = "获取品牌信息")
    public ResultData<BrandRespVo> getBrand(@Validated CodeReqVo reqVo) {
        return ResultUtil.success(webSchoolService.getBrand(reqVo));
    }

    @PutMapping("/updateBrand")
    @ApiOperation(value = "修改品牌信息")
    @SystemLog(description = "修改品牌信息")
    public ResultData updateBrand(@Validated({UpdateGroup.class}) @RequestBody BrandReqVo reqVo) {
        webSchoolService.updateBrand(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/brandPage")
    @ApiOperation(value = "品牌分页")
    public ResultData<PageResult<BrandRespVo>> brandPage(@Validated NameAndPhonePageReqVo reqVo) {
        return ResultUtil.success(webSchoolService.brandPage(reqVo));
    }

}
